<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
</head>
<body>
<div id="app">
    <h2>猜数字游戏</h2>
    输入：<input v-model="input_number"/>
    <button @click="funA">确定</button>
    <hr/>
    随机数是：{{number}} 猜的数字是：{{input_number}} 是否正确：{{result}}
</div>
</body>
</html>
<script src="../js/vue.min.js"></script>
<script>
    new Vue({
        el: '#app',
        data() {
            return {
                number: '',
                input_number: 0,
                result: ''
            }
        },
        methods: {
            funA() {
                this.number = Math.floor(Math.random() * 100 + 1)
                if (this.input_number === this.number) {
                    this.result = '猜对了'
                } else {
                    this.result = '猜错了'
                }
            }
        }
    })
</script>
